<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <script>

    // https://blog.csdn.net/qq_42880714/article/details/132051605
    let obj = {
        _value: 100,
        get value() {
            return this._value;
        },
        set value(v) {
            this._value = v;
        },
        toJSON() {
            return { value: this._value };
        }
    };
    
    const jsonString = JSON.stringify(obj);
    console.log(jsonString); // {"_value":100}




    </script>
</head>

<body>

</body>

</html>